<template>
  <el-dialog :title="'入库'" :close-on-click-modal="false" :visible.sync="visible">
    <el-row>
      <el-table
        :data="dataList"
        border
        v-loading="dataListLoading"
        style="width: 100%;"
        :header-cell-style="{background:'#17b3a3',color:'#fff'}"
      >
        <el-table-column prop="goodsName" header-align="center" align="center" label="商品名称"></el-table-column>
        <el-table-column prop="catName" header-align="center" align="center" label="商品分类"></el-table-column>
        <el-table-column prop="goodsUnit" header-align="center" align="center" label="单位"></el-table-column>
        <!-- <el-table-column prop="goodsPrice" header-align="center" align="center" label="单价"></el-table-column> -->
        <el-table-column prop="num" header-align="center" align="center" label="数量"></el-table-column>
      </el-table>
    </el-row>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      formId: null,
      visible: false,
      dataList: [],
      dataListLoading: false
    };
  },
  methods: {
    init(formId) {
      this.formId = formId;
      this.visible = true;
      this.$nextTick(() => {
        this.getDataList();
      });
    },
    // 获取数据列表
    getDataList() {
      this.dataList = [];
      this.dataListLoading = true;
      this.$http({
        url: this.$http.adornUrl(
          `/merchant/shop/stock/applyForm/goods-list/${this.formId}`
        ),
        method: "get",
        params: this.$http.adornParams({})
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.dataList = data.data;
        }
        this.dataListLoading = false;
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    shopChange(data, node) {
      if (node.level != 2) {
        this.$message.error("请选择店铺");
        return;
      }
      this.dataForm.shopId = data.id;
      this.dataForm.shopName = data.name;
    },
    getCompanyShopTree() {
      this.shopTree = [];
      this.$http({
        url: this.$http.adornUrl(`/merchant/shop/getCompanyShopTree`),
        method: "get",
        params: this.$http.adornParams({})
      }).then(({ data }) => {
        if (data && data.code === 0) {
          if (data.data && data.data.length > 0) {
            this.shopTree = data.data;
            console.log(this.shopTree);
          }
        }
      });
    }
  }
};
</script>
